<template>
  <div>
    <!-- 渲染角色列表 -->
    <el-checkbox-group v-model="checkList">
      <el-checkbox v-for="role in roleList" :key="role.id" :label="role.id">
        <span> {{ role.name }}</span>
      </el-checkbox>
    </el-checkbox-group>

    <el-row class="footer" type="flex" justify="center">
      <el-col :span="6">
        <el-button type="primary" size="small" @click="confirmDialog">确定</el-button>
        <el-button size="small" @click="cancleDialog">取消</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'AssignRole',
  props: {
    roleList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      checkList: []
    }
  },
  methods: {
    // 取消弹框
    cancleDialog() {
      this.$emit('update:show', false)
    },

    confirmDialog() {
      this.$emit('addRoleEV', this.checkList)
      this.$emit('update:show', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.footer {
  margin-top: 30px;
}
</style>
